<?php

$series = $module->message;

?>

<?php if( $series->hasMessages() ): ?>
<ul class="block-grid four-up messages-module">
  <?php foreach( $series->getMessages() as $m ): ?>
  <li class="message">

    <figure>
      <?php if( $m->hasVideo() ) : ?>
      <?php $tracking = sprintf($series->tracking, $series->getTitle() . $m->getShortDate() .  "/video.html"); ?>
      <a href='<?= $m->getVideo() ?>' title='watch <?= $m->getTitle() ?>' <?= $tracking ?> target="_blank">
        <img src="<?= $m->getVimeoData()->thumbnail_medium ?>" />
      </a>
      <?php else: ?>
      <img src="http://placehold.it/200x150&text=<?= $m->getTitle() ?>" />
      <?php endif ?>
    </figure>

    <p class='title'>Week <?= $m->getWeek() ?>: <?= $m->getTitle() ?></p>
    <p class="details">
      by <?= $m->getSpeaker() ?>
      <time><?= $m->getDate() ?></time>
    </p>

    <ul class="media">
      <?php if( $m->hasVideo()) : ?>
      <?php $tracking = sprintf($series->tracking, $series->getTitle() . $m->getShortDate() .  "/video.html"); ?>
      <li class="watch">
        <a href='<?= $m->getVideo() ?>' title='watch <?= $m->getTitle() ?>' <?= $tracking ?> target="_blank">Watch</a>
      </li>
      <?php endif ?>
      <?php if( $m->hasAudio()) : ?>
      <?php $tracking = sprintf($series->tracking, $series->getTitle() . $m->getShortDate() .  "/audio.html"); ?>
      <li class="listen">
        <a href='<?= $m->getAudio() ?>' title='listen to <?= $m->getTitle() ?>' <?= $tracking ?> target="_blank">Listen</a>
      </li>
      <?php endif ?>
    </ul>
  </li>
  <?php endforeach ?>
</ul>
<?php else: ?>
<p>We don’t have any sermons ready yet. Please check back soon!</p>
<?php endif ?>
